<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function pen (naem,age){
            this.naem = naem;
            this.age = age;
        }
        pen.prototype.run = function(){
                console.log('runing');
        }

       function myNew (constr,...src){
          const obj = {}

         const re= constr.apply(obj,src)

         obj.__proto__= constr.prototype;

         if(typeof re==='object' &&  re!=='null' || typeof re==='function'){
                return re
         }else{
            return obj
         }
       }
        const p1 =myNew(pen,'laoliu',81)

     
        console.log(p1);
    </script>
</body>
</html>